package cn.bkrc.RedisTest;

import cn.bkrc.redis.RedisUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class Redis_StringTest {
    //注入RedisUtil工具类
    @Autowired
    RedisUtils redisUtil;
    //写入缓存
    @Test
    public void set() {
        redisUtil.set("name","lisi");
    }

    //读取缓存
    @Test
    public void get(){
        String name=redisUtil.get("name");
        System.out.println("name:"+name);
    }
    //更新缓存
    @Test
    public void getAndSet(){
        redisUtil.getAndSet("name","zhangsan");
    }
    //删除缓存
    @Test
    public void delete(){
        redisUtil.delete("name");
    }
}

